<?php
/**
 * @author Voislav Jovanovic <voislavj@gmail.com>
 * main entry point for the framework
 */


/**
 * Convert Class name (camelcase) to file name
 * @param String $ClassName
 */
function class2file($className) {
	$ret = "";
	for($i=0; $i<strlen($className); $i++) {
		$c = substr($className, $i, 1);
		if($c==strtoupper($c) && $i>0) {
			$c = "_$c";
		}
		$ret .= strtolower($c);
	}
	return $ret;
}
/**
 * Convert file name to Class Name (camelcase)
 * @param String $file_name
 */
function file2class($filename) {
	$ret = preg_replace('/_(.)/e', "strtoupper('\\1')", $filename);
	$ret = preg_replace('/^(.)/e', "strtoupper('\\1')", $ret);
	return $ret;
}

/**
 * Dump variable into output
 * @param Mixed $variable
 */
function _dump($var) {
	echo '<pre>';
	if(is_array($var) || is_object($var)) {
		print_r($var);
	}else if(is_bool($var) || is_null($var) || empty($var)) {
		var_dump($var);
	}else{
		echo $var;
	}
	echo '</pre>';
}
/**
 * Redirect to URL
 * @param String $url [/]
 */
function redirect($url = ""){
	$url = preg_replace('/\/+$/', '', DIR_BASE) . "/" . preg_replace('/^\/+/', '', $url);
	ob_get_contents();
	ob_clean();
	header("Location: $url");
	die;
}

?>